package com.niiwoo.civet.scheduler.trigger;

import com.alibaba.dubbo.config.annotation.Reference;
import com.niiwoo.civet.trade.service.loan.SpeedLoanDubboService;
import com.niiwoo.civet.trade.service.project.ProjectDubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 借款相关定时器
 * @author xueyuke
 * @date 2017-11-30
 */
@Component
public class LoanJobTrigger {
    private static final Logger logger= LoggerFactory.getLogger(LoanJobTrigger.class);

    @Reference(version = "1.0.0")
    private SpeedLoanDubboService speedLoanDubboService;

    @Reference(version = "1.0.0")
    private ProjectDubboService projectDubboService;

    /**
     * 推标
     */
    @Scheduled(cron = "${loan.push-project}")
    public void pushProjectScan(){
        speedLoanDubboService.pushProjectScan();
    }

    /**
     * 通讯录回流成功标的扫描
     */
    @Scheduled(cron = "${loan.address-list-risk-rule}")
    public void addressList4RiskRuleScan(){
        speedLoanDubboService.addressList4RiskRuleScan();
    }

    /**
     * 通讯录待回流标的扫描
     */
    @Scheduled(cron = "${loan.address-list}")
    public void addressListScan(){
        speedLoanDubboService.addressListScan();
    }

    /**
     * 通讯录回流超时退回标的扫描
     */
    @Scheduled(cron = "${loan.address-list-timeout}")
    public void addressListTimeoutScan(){
        speedLoanDubboService.addressListTimeoutScan();
    }

    /**
     * 风险规则回调扫描
     */
    @Scheduled(cron = "${loan.risk-rule}")
    public void riskRuleScan(){
        speedLoanDubboService.riskRuleTimeoutScan();
    }

    /**
     * 清除风险规则回调扫描
     */
    @Scheduled(cron = "${loan.clean-call_risk_rule_record}")
    public void cleanCallRiskRuleRecord(){
        speedLoanDubboService.cleanCallRiskRuleRecord();
    }

    /**
     * 退回超时流标扫描
     */
    @Scheduled(cron = "${loan.flow_return_timeout_project}")
    public void flowReturnTimeoutProjectScan(){
        speedLoanDubboService.flowReturnTimeoutProjectScan();
    }

    /**
     * 标的待发布转发布扫描
     */
    @Scheduled(cron = "${loan.project_wait_publish_to_publish:0 */5 * * * ?}")
    public void projectWaitPublishToPublishScan(){
        projectDubboService.projectWaitPublishToPublishScan();
    }
}
